<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>限流函数</title>
        <script src="https://unpkg.com/vue@3.5.13"></script>
        <script src="https://unpkg.com/lodash@4.17.20/lodash.min.js"></script>
    </head>
    <body>
        <div id="Application">
            <button @click="click">按钮</button>
        </div>
        <script>
            var throttle = false

            // 自定义节流函数
            function throttleTool(callback, timeout) {
                if (!throttle) {
                    callback()
                } else {
                    return
                }
                throttle = true
                setTimeout(() => {
                    throttle = false
                }, timeout)
            }

            const App = {
                methods: {
                    click: _.debounce(function () {
                        console.log(Date())
                    },2000)
                }
            }
            Vue.createApp(App).mount('#Application')
        </script>
    </body>
</html>